<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<meta http-equiv="keywords" content="" />
		<meta http-equiv="description" content="" />
		<title>コントロールパネル</title>

		<link rel="stylesheet" href="./assets/styles/default.css" type="text/css" />
		<script src="assets/scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
		<script src="assets/scripts/menu.js" type="text/javascript"></script>
		<script src="assets/scripts/table.js" type="text/javascript"></script>
		<style type="text/css">
			.nobinput{
				border-width: 0px;
				font-family: inherit;
				padding: 3px 5px;
				text-align: center;
			}
			.nobinput2{
				border-width: 0px;
				font-family: inherit;
				padding: 3px 5px;
				/*text-align: center;*/
			}
		</style>
		<script src="assets/scripts/ui/jquery-ui-1.7.2.custom.js" type="text/javascript"></script>
		<link type="text/css" href="./assets/styles/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
		<script type="text/javascript" src="./assets/scripts/ui/ui.core.js"></script>
		<script type="text/javascript">
		
		$(function() {

			// メッセージのフェード
			$('.message').fadeIn("slow");

			// 戻るボタン押下
			$('#btn_back').click(function(){
				document.fm.mode.value = 'back';
				document.fm.submit();
			});
			
		});
		</script>	
		
		<script type="text/javascript">
		
			function deleteAction(id){
				if(confirm("削除してもよろしいでしょうか?")){
					window.location.href='make_price.php?consumer_id={{$consumer.consumer_id}}&price_no='+id+'&&mod=delete';
				}else{
					return false;
				}
			} 

			//コントロールお客様は状態に同意する
			function controlStatus(){
				document.getElementById("status").style.display = 'block';
				document.getElementById("status1").style.display = 'none';
			}
		</script>
		
		<script type="text/javascript">
			

			function controlPayment_term(){
				var payment_term = document.getElementById("payment_term");
				var payment1 = document.getElementById("payment1");
				var payment2 = document.getElementById("payment2");
				if(payment2.checked){
					payment_term.readOnly = false;
				}
				if(payment1.checked){
					payment_term.readOnly = true;
				}
			}
		</script>
		
		<!--タイムコントロール -->
		<script>
			$(document).ready(function(){ 
				$("#start_date").wrDate();  
				$("#end_date").wrDate();
				$("#start_date1").wrDate();  
				$("#end_date1").wrDate();
			});
	
			$.extend({ 
				wrDate : function(objs) { 
				objs.each(function(i) { 
					//jQueryオブジェクトをトラバース
					var inputObj = $(this); 
					inputObj.datepicker({
						changeMonth: true,
						changeYear: true,
						dateFormat: 'yy/mm/dd'
					}); //各jQueryオブジェクトにCalendarコントロール
				}); 
			}});
	
			$.fn.extend({ 
				wrDate : function() { 
				//wrDate jQueryプラグインの名前を定義します
				$.wrDate(this); //呼び出す前に、カスタムjQuery関数 
			}});
			
		</script>	
		
		<script language="javascript"> 
		      function openWin(u, w, h) { 
		            var l = (screen.width - w) / 2; 
		            var t = (screen.height - h) / 2; 
		            var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l; 
		            s += ', toolbar=no, scrollbars=yes, menubar=yes, location=no, resizable=yes'; 
		            open(u, 'oWin', s); 
		      } 
		      
		      var shopids = [];
		      
		      {{ foreach from=$detail key=k item=v }}
		      	shopids.push({{$v.shop_id}});
		      {{/foreach}}
		      
		      function validationRepeat(id,clickid){
		    	  /*
		    	  if(document.getElementById("shop_id_"+clickid).value!=''){
		    		  for(var i=0;i<shopids.length;i++){
			    		  if(shopids[i]==document.getElementById("shop_id_"+clickid).value){
			    			  shopids[i] = 0;
			    		  }
			    	  }
		    	  }
		    	  
		    	  for(var i=0;i<shopids.length;i++){
		    		  if(shopids[i]==id){
		    			  return false;
		    		  }
		    	  }
		    	  shopids.push(id);
		    	  */
		    	  return true;
		      }
		      
		      function priceChange(id){
		    	  	var refer_price =  (document.getElementById("refer_price_"+id).value);
					var multiple =  (document.getElementById("multiple_"+id).value);
					var num = (document.getElementById("num_"+id).value);
					var cost_price = (document.getElementById("cost_price_"+id).value);
					
					if(num=='' || multiple==''){
						return ;
					}
					
					if(isNaN(refer_price) || isNaN(multiple) || isNaN(num) || isNaN(cost_price)){
						alert("半角数字で入力して下さい");
						return ;
					}
					refer_price = parseFloat(refer_price);
					multiple = parseFloat(multiple);
					num = parseFloat(num);
					cost_price = parseFloat(cost_price);
					document.getElementById("money_"+id).innerHTML=formatNumber(parseInt((refer_price)*(multiple)*(num)));
					var m = parseFloat(refer_price)*multiple*num;
					var o = parseFloat(cost_price)*num;
					document.getElementById("profit_"+id).innerHTML=parseInt(((m-o)/m)*100)+"%";
					
					compute();
					
		      }
		      
		      function compute(){
		    	  
		    	  var m1 = 0;
					for(var i=1;i<=10;i++){
						if(document.getElementById("money_"+i).firstChild != null){
							var tempv=document.getElementById("money_"+i).firstChild.nodeValue;
							var value = tempv.replace(",","");
							m1 = m1 + parseFloat(value);
						}
						
					}
					
					m1 = m1.toFixed(2);
					var m2 = m1 * {{$tax}};
					m2=m2.toFixed(2);
					var m3 = parseFloat(m1) + parseFloat(m2);
					m3 = m3.toFixed(2);
					
					document.getElementById("m1").innerHTML=formatNumber(parseInt(m1));
					document.getElementById("m2").innerHTML=formatNumber(parseInt(m2));
					document.getElementById("m3").innerHTML=formatNumber(parseInt(m3));
		      }
		      
		      function validation(){
		    	  for(var i=1;i<=10;i++){
						if(document.getElementById("shop_id_"+i).value > 0){
							var multiple = document.getElementById("multiple_"+i).value;
							var num = document.getElementById("num_"+i).value;
							if(isNaN(multiple) || isNaN(num)){
								alert("半角数字で入力して下さい");
								return false;
							}
							
							if(multiple==''){
								alert("半角数字で入力して下さい");
								document.getElementById("multiple_"+i).focus();
								return false;
							}
							
							if(num==''){
								alert("半角数字で入力して下さい");
								document.getElementById("num_"+i).focus();
								return false;
							}
							
						}
						
					}
		    	  return true;
		      }
		      
		      function formatNumber(str) {
		    	  	str=str+"";
				    if(str.length <= 3){  
				        return str;  
				    } else {  
				        return formatNumber(str.substr(0,str.length-3))+','+str.substr(str.length-3);  
				    }  
				}
		      
		      function yes(){
		    	  document.getElementById("mod").value = "yes";
		    	  document.getElementById("mpform").submit();
		    	  
		      }
		</script> 
			
	</head>
	
	<body >
{{ php }} include( MENU_FILE ); {{ /php }}
		<div id="header" class="clearfix"><div class="wrapper">
			<h1><a href="./">コントロールパネル</a></h1>
			<form id="form_logout" action="logout.php" method="post"><p>{{ $login.staff_name }} <input type="submit" id="button_logout" value="ログアウト" /></p></form>
		</div></div>

		<div id="container">
		<div class="wrapper">
			<h2>見積管理</h2>
			<ul class="submenu clearfix">
				<li><a href="consumer_index.php">顧客検索</a></li>								
				<li><a href="consumer_form.php">顧客登録</a></li>
				<li><a href="price_task.php">見積タスク一覧</a></li>
				<li><a href="price_check.php">見積検索</a></li>
				<li><a href="shop_index.php">商品マスタ</a></li>
			</ul>
			
			<h3>見積書作成</h3>
			{{ if $phase == 'complete' }}
			<p class="message">作成完了しました</p>
			<ul>
				<li>&gt;&gt; <a href="consumerInfo.php?consumer_id={{$consumer_id}}">一覧へ戻る</a></li>
			</ul>
			{{ elseif $phase == 'completecopy' }}
			<p class="message">コピーして完了</p>
			<ul>
				<li>&gt;&gt; <a href="consumerInfo.php?consumer_id={{$consumer_id}}">一覧へ戻る</a></li>
			</ul>
			{{ elseif $phase == 'completeupdate' }}
			<p class="message">更新が完了しました</p>
			<ul>
				<li>&gt;&gt; <a href="{{php}}echo $_SESSION['HTTP_REFERER'];{{/php}}">一覧へ戻る</a></li>
			</ul>
			{{ elseif $phase == 'completeyes' }}
			<p class="message">客先同意処理を完了しました</p>
			<ul>
				<li>&gt;&gt; <a href="consumerInfo.php?consumer_id={{$consumer_id}}">一覧へ戻る</a></li>
			</ul>
			{{ elseif $phase == 'completerequest' }}
			<p class="message">承認依頼をかけました</p>
			<ul>
				<li>&gt;&gt; <a href="consumerInfo.php?consumer_id={{$consumer_id}}">一覧へ戻る</a></li>
			</ul>
			{{ else }}
			<h4>見積書一覧</h4>
			<ul>			
				<!-- <li>＞ <a href="{{$pre_page_url}}">戻る</a></li> -->
				<li>＞ <a href="{{php}}echo $_SESSION['HTTP_REFERER'];{{/php}}">戻る</a></li>
			</ul>
			
			<p class="message">見積書作成</p>
			
			{{ if $flag == 1 }}
			<div id="mydiv3" style="width: 90%;border: 1px solid #ccc;">
			
			<form action="make_price.php" method="post" onsubmit="return validation() " id="mpform">
					<input type="hidden" name="mod" value="insert" id="mod" />
					<div style="width: 98%;margin-left:7px;">
						<div style="float: left;"><span style="font-size: 20px;">見積書作成</span></div>
						
					</div>
					<div style="clear: both;"></div>
					<table  class="formTable" style="width: 98%;margin-left:7px;">
						<thead>
							<tr>
								<th>見積番号</th>
								<td>{{$price_no}}</td>
								<input type="hidden" name="price_no" value="{{$price_no}}" />
							</tr>
							
							<tr>
								<th>得意先名</th>
								<td>{{$consumer.company_name}}</td>
								<input type="hidden" name="consumer_id" value="{{$consumer.consumer_id}}" />
								<input type="hidden" name="company_name" value="{{$consumer.company_name}}" />
							</tr>
							<tr>
								<th>作成者</th>
								<td>{{$staff_name}}</td>
								<input type="hidden" name="producer" value="{{$staff_name}}" />
							</tr>
							<tr>
								<th>※支払条件</th>
								<td>
									<input type="radio"  name="payment" value="1" {{ if $forms.payment == 1 || $forms.payment=='' }}checked="checked"{{ /if }}  />&nbsp;&nbsp;{{$consumer.payment_term}}<br/>
									<input type="radio"  name="payment" value="2" {{ if $forms.payment == 2  }}checked="checked"{{ /if }}  />&nbsp;&nbsp;特別条件&nbsp;&nbsp;<input type="text" name="payment_term" id="payment_term" class="text" /> {{ $err.payment_term }}
								</td>
							</tr>
							<tr>
								<th>※件名</th>
								<td>
									<select id="text_information" name="pro_name" class="text">
									{{ foreach from=$make_price_option key=k item=v }}
										<option value="{{$k}}" {{if $forms.pro_name == $k }} selected {{/if}} >{{$v}}</option>
									{{ /foreach }}
									</select>
									
								</td>
							</tr>
							<tr>
								<th>※纳入場所</th>
								<td><input name="save_address" type="text" id="text_information" class="text" value='{{$forms.save_address}}' /> {{ $err.save_address }}</td>
								
							</tr>
							<tr>
								<th>※纳入期日</th>
								<td><input name="save_date" type="text" id="text_information" class="text" value="{{$forms.save_date}}"/> {{ $err.save_date }}</td>
							</tr>							
							<tr>
								<th>※適用期間</th>
								<td>
									<input name="period_remark" type="text" class="text" value="{{$forms.period_remark}}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									開始日&nbsp;&nbsp;<input size="10" name="period_str" value="{{$forms.period_str}}" type="text" id="start_date" class="text"/>&nbsp;&nbsp;&nbsp;&nbsp;
									終了日&nbsp;&nbsp;<input size="10" name="period_end" value="{{$forms.period_end}}" type="text" id="end_date" class="text"/> {{ $err.period }}
								</td>
							</tr>
							<tr>
								<th>※見積有効期限</th>
								<td><input name="dateestimated" type="text" id="text_information" class="text" value="{{$forms.dateestimated}}"/> {{ $err.dateestimated }}</td>
							</tr>
							<tr>
								<th>※送料</th>
								<td>
									<select id="text_information" name="shipping">
										<option value="送料は8,000円未満のご注文で500円とさせていただきます。" {{ if $forms.shipping == '送料は8,000円未満のご注文で500円とさせていただきます。'  }}selected{{ /if }}>送料は8,000円未満のご注文で500円とさせていただきます。</option>
										<option value="送料なし" {{ if $forms.shipping == '送料なし'  }}selected{{ /if }}>送料なし</option>
										<option value="送料は備考参照" {{ if $forms.shipping == '送料は備考参照'  }}selected{{ /if }}>送料は備考参照</option>
									</select>
								</td>
							</tr>
						</thead>
					
					</table>
					
					
					<table class="formTable" style="width: 98%;margin-left:7px;">
	
							<tr align="center">
								<th>マスタ選択</th>
								<th style="width:280px">商品名</th>
								<th>単価</th>
								<th>掛率</th>
								<th>数量</th>
								<th>単位</th>		
								<th>金額</th>			
								<th>利益率</th>		
							</tr>
							<!-- 
							{{section name=foo start=1 loop=11 step=1 }}
							<input type="hidden" name="cost_price[]" id="cost_price_{{$smarty.section.foo.index}}" value="0" />
							<input type="hidden" name="shop_id[]" id="shop_id_{{$smarty.section.foo.index}}" value="0" />
							<input type="hidden" name="style[]" id="style_{{$smarty.section.foo.index}}" value="" />
							<tr>
								<td align="center"><a href="javascript:void(openWin('shop_search.php?id={{$smarty.section.foo.index}}', 600, 500));">[マスタ選択]</a></td>
								<td><input type="text" name="shop_name[]" id="shop_name_{{$smarty.section.foo.index}}"   class="nobinput" readonly="readonly" /></td>
								<td align="center"><input type="text" name="refer_price[]" id="refer_price_{{$smarty.section.foo.index}}"  class="nobinput" style="width: 35px;" readonly="readonly" /></td>
								<td align="center"><input type="text" name="multiple[]" id="multiple_{{$smarty.section.foo.index}}" class="text"  style="width: 35px;" onblur="priceChange({{$smarty.section.foo.index}})" /></td>
								<td align="center"><input type="text" name="num[]" id="num_{{$smarty.section.foo.index}}" class="text" style="width: 35px;" onblur="priceChange({{$smarty.section.foo.index}})"  /></td>
								<td align="center"><input type="text" name="s_unit[]" id="s_unit_{{$smarty.section.foo.index}}"  class="nobinput" style="width: 35px;" readonly="readonly" /></td>
								<td align="center"><span id="money_{{$smarty.section.foo.index}}"></span></td>
								<td align="center"><span id="profit_{{$smarty.section.foo.index}}"></span></td>						
							</tr>
							{{/section}}
							-->
							
							{{ foreach from=$detail key=k item=v }}
							<input type="hidden" name="cost_price[]" id="cost_price_{{$k+1}}" value="{{$v.cost_price}}" />
							<input type="hidden" name="shop_id[]" id="shop_id_{{$k+1}}" value="{{$v.shop_id}}" />
							<input type="hidden" name="did[]"  value="{{$v.did}}" />
							<input type="hidden" name="style[]" id="style_{{$k+1}}" value="{{$v.style}}" />
							<tr>
								<td align="center"><a href="javascript:void(openWin('shop_search.php?id={{$k+1}}', 720, 580));">[マスタ選択]</a></td>
								<td>
								<span id="shop_name_span_{{$k+1}}">{{$v.shop_name}}</span>
								<input type="hidden" name="shop_name[]" id="shop_name_{{$k+1}}" value="{{$v.shop_name}}"   class="nobinput" readonly="readonly" />
								</td>
								<td align="center"><input type="text" name="refer_price[]" id="refer_price_{{$k+1}}" value="{{$v.refer_price}}"  class="nobinput" style="width: 55px;text-align: center;" readonly="readonly"/></td>
								<td align="center"><input type="text" name="multiple[]" id="multiple_{{$k+1}}" value="{{$v.discount}}" class="text"  style="width: 55px;text-align: center;" onblur="priceChange({{$k+1}})" /></td>
								<td align="center"><input type="text" name="num[]" id="num_{{$k+1}}" class="text" value="{{$v.quantity}}" style="width: 55px;text-align: center;" onblur="priceChange({{$k+1}})"  /></td>
								<td align="center"><input type="text" name="s_unit[]" id="s_unit_{{$k+1}}" value="{{$v.s_unit}}" class="nobinput" style="width: 35px;" readonly="readonly"/></td>
								<td align="center"><span id="money_{{$k+1}}">{{$v.money}}</span></td>
								<td align="center"><span id="profit_{{$k+1}}">{{$v.profit}}%</span></td>						
							</tr>
							{{ /foreach }}
							{{section name=foo start=$num loop=21 step=1 }}
							<input type="hidden" name="cost_price[]" id="cost_price_{{$smarty.section.foo.index}}" value="0" />
							<input type="hidden" name="shop_id[]" id="shop_id_{{$smarty.section.foo.index}}" value="0" />
							<input type="hidden" name="did[]"  value="0" />
							<input type="hidden" name="style[]" id="style_{{$smarty.section.foo.index}}" value="" />
							<tr>
								<td align="center"><a href="javascript:void(openWin('shop_search.php?id={{$smarty.section.foo.index}}', 720, 580));">[マスタ選択]</a></td>
								<td>
								<span id="shop_name_span_{{$smarty.section.foo.index}}"></span>
								<input type="hidden" name="shop_name[]" id="shop_name_{{$smarty.section.foo.index}}"   class="nobinput" readonly="readonly" />
								</td>
								<td align="center"><input type="text" name="refer_price[]" id="refer_price_{{$smarty.section.foo.index}}"  class="nobinput" style="width: 55px;text-align: center;" readonly="readonly" /></td>
								<td align="center"><input type="text" name="multiple[]" id="multiple_{{$smarty.section.foo.index}}" class="text"  style="width: 55px;text-align: center;" onblur="priceChange({{$smarty.section.foo.index}})" /></td>
								<td align="center"><input type="text" name="num[]" id="num_{{$smarty.section.foo.index}}" class="text" style="width: 55px;text-align: center;" onblur="priceChange({{$smarty.section.foo.index}})"  /></td>
								<td align="center"><input type="text" name="s_unit[]" id="s_unit_{{$smarty.section.foo.index}}"  class="nobinput" style="width: 35px;" readonly="readonly" /></td>
								<td align="center"><span id="money_{{$smarty.section.foo.index}}"></span></td>
								<td align="center"><span id="profit_{{$smarty.section.foo.index}}"></span></td>						
							</tr>
							{{/section}}
		
					</table>
					
				  
					<div style="width: 98%;text-align: center;margin-left:7px;">
						
						<div style="float: left;margin-top: 20px;">
							<div style="margin-left: 20px;">備考&diams;&nbsp;<textarea  name="remark" class="text" style="width: 360px" />{{$forms.remark}}</textarea></div>
							<div style="margin-top: 10px;">特価理由&diams;&nbsp;<textarea name="special_reason" class="text"  style="width: 360px" />{{$forms.special_reason}}</textarea>	</div>						
						</div>
						
						<div id="mydiv5" style="float: right;display: block;">
							<div>税抜合計金額：￥<span id="m1">0</span></div>
							<div>　　消費税：￥<span id="m2">0</span></div>
							<div>税込合計金額：￥<span id="m3">0</span></div>
						</div>					 
						<br/><br/>
					</div>
				  
					<br/>
								
					<div id="status" style="display: none;border: 1px solid;width: 35%;float: right;margin-right:18px;">
						<div>客先同意</div>
						<div>
							<p class="button">
								<button type="button" class="submit" ><span>OK</span></button>
								<button type="button" class="submit" ><span>NG</span></button>
							</p>
						</div>
					</div>									
					
					<!-- 
					<div id="status1" style="width: 98%;margin-left:120px;display: block;">
						<p class="button">
							<button type="button" class="submit" onclick="controlStatus()" ><span>客先同意</span></button>
						</p>
					</div>
					 -->
					<div style="width: 98%;text-align: center;margin-left:7px;">
						<p class="button">
							<!-- <button type="button" class="submit" style="float: left;margin-left:7px;" onclick="controlRdiv()"/><span>削除</span></button> 
							<button type="button" class="submit" ><span>単価稟議書印刷</span></button>
							<button type="button" class="submit" ><span>見積書印刷</span></button>
							<button type="button" class="submit" ><span>承認依頼する</span></button>
							-->
							<button type="button" class="submit" onclick="yes()" ><span>承認依頼する</span></button>
							<button type="submit" class="submit" ><span>保存</span></button>
						</p>
					</div>
					</form>					
			</div>
				
			{{ else }}
			
			<script>
			
			function copy(){
				document.getElementById("mod").value='copy';
				document.getElementById("m").submit();
				
			}
			
			</script>
			
			<div id="mydiv4" style="width: 90%;border: 1px solid #ccc;">
			
				<form action="make_price.php" method="post" onsubmit="return validation() " id="m">
					<input type="hidden" name="mod" value="update" id="mod" />
					<div style="width: 98%;margin-left:7px;">
						<div style="float: left;"><span style="font-size: 20px;">見積書作成</span></div>
						<div style="float: right;">
							<p class="button" style="width: 160px"><button type="button" onclick="openWin('consumer_select.php?price_no={{$price_no }}&consumer_id={{$consumer_id}}',600,450)" ><span style="font-size:11px">コピー新規作成</span></button></p>
						</div>
					</div>
					<div style="clear: both;"></div>
					<table  class="formTable" style="width: 98%;margin-left:7px;">
						<thead>
							<tr>
								<th>見積番号</th>
								<td>{{$price_no}}</td>
								<input type="hidden" name="price_no" value="{{$price_no}}" />
							</tr>
							
							<tr>
								<th>得意先名</th>
								<td>{{$consumer.company_name}}</td>
								<input type="hidden" name="consumer_id" value="{{$consumer.consumer_id}}" />
								<input type="hidden" name="company_name" value="{{$consumer.company_name}}" />
							</tr>
							<tr>
								<th>作成者</th>
								<td>{{$staff_name}}</td>
								<input type="hidden" name="producer" value="{{$staff_name}}" />
							</tr>
							<tr>
								<th>※支払条件</th>
								<td>
									<input type="radio"  name="payment" value="1" {{ if $forms.payment == 1 || $forms.payment=='' }}checked="checked"{{ /if }}  />&nbsp;&nbsp;{{$consumer.payment_term}}<br/>
									<input type="radio"  name="payment" value="2" {{ if $forms.payment == 2 || $forms.payment_term !=''}}checked="checked"{{ /if }}  />&nbsp;&nbsp;特別条件&nbsp;&nbsp;<input type="text" name="payment_term" id="payment_term" class="text" value="{{$forms.payment_term}}" /> {{ $err.payment_term }}
								</td>
							</tr>
							<tr>
								<th>※件名</th>
								<td>
									<select id="text_information" name="pro_name" class="text">
									{{ foreach from=$make_price_option key=k item=v }}
										<option value="{{$k}}" {{if $forms.pro_name == $k }} selected {{/if}} >{{$v}}</option>
									{{ /foreach }}
									</select>
									
								</td>
							</tr>
							<tr>
								<th>※纳入場所</th>
								<td><input name="save_address" type="text" id="text_information" class="text" value='{{$forms.save_address}}' /> {{ $err.save_address }}</td>
								
							</tr>
							<tr>
								<th>※纳入期日</th>
								<td><input name="save_date" type="text" id="text_information" class="text" value='{{$forms.save_date}}' /> {{ $err.save_date }}</td>
							</tr>							
							<tr>
								<th>※適用期間</th>
								<td>
									<input name="period_remark" type="text" class="text" value='{{$forms.period_remark}}' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									開始日&nbsp;&nbsp;<input size="10" name="period_str" type="text" id="start_date1" class="text" value='{{$forms.period_str}}'/>&nbsp;&nbsp;&nbsp;&nbsp;
									終了日&nbsp;&nbsp;<input size="10" name="period_end" type="text" id="end_date1" class="text" value='{{$forms.period_end}}'/> {{ $err.period }}
								</td>
							</tr>
							<tr>
								<th>※見積有効期限</th>
								<td><input name="dateestimated" type="text" id="text_information" class="text" value='{{$forms.dateestimated}}'/> {{ $err.dateestimated }}</td>
							</tr>
							<tr>
								<th>※送料</th>
								<td>
									<select id="text_information" name="shipping" class="text">
										<option value="送料は8,000円未満のご注文で500円とさせていただきます。" {{ if $forms.shipping == '送料は8,000円未満のご注文で500円とさせていただきます。'  }}selected{{ /if }}>送料は8,000円未満のご注文で500円とさせていただきます。</option>
										<option value="送料なし" {{ if $forms.shipping == '送料なし'  }}selected{{ /if }}>送料なし</option>
										<option value="送料は備考参照" {{ if $forms.shipping == '送料は備考参照'  }}selected{{ /if }}>送料は備考参照</option>
									</select>
								</td>
							</tr>
						</thead>
					
					</table>
					
					
					<table class="formTable" style="width: 98%;margin-left:7px;">
	
							<tr align="center">
								<th>マスタ選択</th>
								<th style="width:280px">商品名</th>
								<th>単価</th>
								<th>掛け率</th>
								<th>数量</th>
								<th>単位</th>		
								<th>金額</th>			
								<th>利益率</th>		
							</tr>
							{{ foreach from=$detail key=k item=v }}
							<input type="hidden" name="cost_price[]" id="cost_price_{{$k+1}}" value="{{$v.cost_price}}" />
							<input type="hidden" name="shop_id[]" id="shop_id_{{$k+1}}" value="{{$v.shop_id}}" />
							<input type="hidden" name="did[]"  value="{{$v.did}}" />
							<input type="hidden" name="style[]" id="style_{{$k+1}}" value="{{$v.style}}" />
							<tr>
								<td align="center"><a href="javascript:void(openWin('shop_search.php?id={{$k+1}}', 700, 570));">[マスタ選択]</a></td>
								<td>
								<span id="shop_name_span_{{$k+1}}">{{$v.shop_name}}</span>
								<input type="hidden" name="shop_name[]" id="shop_name_{{$k+1}}" value="{{$v.shop_name}}"   class="nobinput" readonly="readonly" />
								</td>
								<td align="center"><input type="text" name="refer_price[]" id="refer_price_{{$k+1}}" value="{{$v.refer_price}}"  class="nobinput" style="width: 55px;text-align: center;" readonly="readonly"/></td>
								<td align="center"><input type="text" name="multiple[]" id="multiple_{{$k+1}}" value="{{$v.discount}}" class="text"  style="width: 55px;text-align: center;" onblur="priceChange({{$k+1}})" /></td>
								<td align="center"><input type="text" name="num[]" id="num_{{$k+1}}" class="text" value="{{$v.quantity}}" style="width: 55px;text-align: center;" onblur="priceChange({{$k+1}})"  /></td>
								<td align="center"><input type="text" name="s_unit[]" id="s_unit_{{$k+1}}" value="{{$v.s_unit}}" class="nobinput" style="width: 35px;" readonly="readonly"/></td>
								<td align="center"><span id="money_{{$k+1}}">{{$v.money}}</span></td>
								<td align="center"><span id="profit_{{$k+1}}">{{$v.profit}}%</span></td>						
							</tr>
							{{ /foreach }}
							{{section name=foo start=$num loop=21 step=1 }}
							<input type="hidden" name="cost_price[]" id="cost_price_{{$smarty.section.foo.index}}" value="0" />
							<input type="hidden" name="shop_id[]" id="shop_id_{{$smarty.section.foo.index}}" value="0" />
							<input type="hidden" name="did[]"  value="0" />
							<input type="hidden" name="style[]" id="style_{{$smarty.section.foo.index}}" value="" />
							<tr>
								<td align="center"><a href="javascript:void(openWin('shop_search.php?id={{$smarty.section.foo.index}}', 700, 570));">[マスタ選択]</a></td>
								<td>
								<span id="shop_name_span_{{$smarty.section.foo.index}}"></span>
								<input type="hidden" name="shop_name[]" id="shop_name_{{$smarty.section.foo.index}}"   class="nobinput" readonly="readonly" />
								</td>
								<td align="center"><input type="text" name="refer_price[]" id="refer_price_{{$smarty.section.foo.index}}"  class="nobinput" style="width: 55px;text-align: center;" readonly="readonly" /></td>
								<td align="center"><input type="text" name="multiple[]" id="multiple_{{$smarty.section.foo.index}}" class="text"  style="width: 55px;text-align: center;" onblur="priceChange({{$smarty.section.foo.index}})" /></td>
								<td align="center"><input type="text" name="num[]" id="num_{{$smarty.section.foo.index}}" class="text" style="width: 55px;text-align: center;" onblur="priceChange({{$smarty.section.foo.index}})"  /></td>
								<td align="center"><input type="text" name="s_unit[]" id="s_unit_{{$smarty.section.foo.index}}"  class="nobinput" style="width: 35px;" readonly="readonly" /></td>
								<td align="center"><span id="money_{{$smarty.section.foo.index}}"></span></td>
								<td align="center"><span id="profit_{{$smarty.section.foo.index}}"></span></td>						
							</tr>
							{{/section}}
		
					</table>
					
				  
					<div style="width: 98%;text-align: center;margin-left:7px;">
						
						<div style="float: left;margin-top: 20px;">
							<div style="margin-left: 20px;">備考&diams;&nbsp;<textarea  name="remark" class="text"  style="width: 360px" />{{$forms.remark}}</textarea></div>
							<div style="margin-top: 10px;">特価理由&diams;&nbsp;<textarea  name="special_reason" class="text"  style="width: 360px" />{{$forms.special_reason}}</textarea>		</div>					
						</div>
						
						<div id="mydiv5" style="float: right;display: block;">
							<div>税抜合計金額：￥<span id="m1">0</span></div>
							<div>　　消費税：￥<span id="m2">0</span></div>
							<div>税込合計金額：￥<span id="m3">0</span></div>
						</div>					 
						<br/><br/>
					</div>
				  
					<br/>
								
					<div id="status" style="display: none;border: 1px solid;width: 35%;float: right;margin-right:300px;">
						<div>客先同意</div>
						<div>
							<p class="button">
								<button type="button" class="submit" onclick="window.location.href='make_price.php?mod=yes&price_no={{$price_no}}&consumer_id={{$consumer.consumer_id}}'" ><span>OK</span></button>
								<button type="button" class="submit" onclick="window.location.href='make_price.php?mod=no&price_no={{$price_no}}&consumer_id={{$consumer.consumer_id}}'" ><span>NG</span></button>
							</p>
						</div>
					</div>									
					
					<div id="status1" style="width: 98%;margin-left:120px;display: block;">
						<p class="button">
						{{if $forms.status==3 }}
							<button type="button" class="submit" onclick="controlStatus()" ><span>客先同意</span></button>
						{{/if}}
						</p>
					</div>
					<input type="hidden" name="status" value="{{$forms.status}}" />
					<div style="width: 98%;text-align: center;margin-left:7px;">
						<p class="button">
							{{if $forms.status==1 || $forms.status==2 || $forms.status==4}}
							<button type="button" class="submit" style="float: left;margin-left:7px;" onclick="deleteAction('{{$price_no}}')"/><span>削除</span></button>
							{{/if}}
							{{if $forms.status==2 || $forms.status==3 || $forms.status==5 }}
							<button type="button" class="submit" onclick="openWin('price_resolution.php?price_no={{$price_no}}&consumer_id={{$consumer.consumer_id}}',800,800)" ><span style="font-size: 11px">単価稟議書印刷</span></button>
							{{/if}}
							{{if $forms.status==3 || $forms.status==5 || $forms.status==6 }}
							<button type="button" class="submit" onclick="openWin('price_book.php?mod=quoteprint&price_no={{$price_no}}&consumer_id={{$consumer.consumer_id}}',800,800)" ><span>見積書印刷</span></button>
							{{/if}}
							{{if $forms.status==1 || $forms.status==4 || $forms.status==6 }}
							<button type="button" class="submit" onclick="window.location.href='make_price.php?mod=request&price_no={{$price_no}}&consumer_id={{$consumer.consumer_id}}'" ><span>承認依頼する</span></button>
							{{/if}}
							{{if $forms.status==1 || $forms.status==4}}
							<button type="submit" class="submit" ><span>保存</span></button>
							{{/if}}
						</p>
					</div>
					</form>					
				</div>
				
				<script>
				compute();
				</script>
				{{ /if }}
		{{ /if }}

		</div></div>
		<br/><br/>
		<address>Copyright (C) SHIFT Inc. / All rights reserved</address>
	</body>

</html>